<?php
require_once ('system/core/Model.php');
class User_Model extends CI_Model {

	function __construct()
	{
		parent::__construct();
	}
	
	
	function insert_user($account,$passowrd,$name,$sex,$major,$birth,$permission,$address,$mark)
	{
		
		$data =array(
				'account'=>$account,
				'password'=>$passowrd,
				'name'=>$name,
				'sex'=>$sex,
				'major'=>$major,
				'birth'=>$birth,
				'permission'=>$permission,
				'address'=>$address,
				'mark'=>$mark);
		$this->db->insert("user",$data);
	}
	
	
	function update_user($account,$password,$name,$sex,$major,$birth,$permission,$address,$mark)
	{
		$data = array(
				'account'=>$account,
				'password'=>$password,
				'name'=>$name,
				'sex'=>$sex,
				'major'=>$major,
				'birth'=>$birth,
				'permission'=>$permission,
				'address'=>$address,
				'mark'=>$mark);
		$this->db->where('account',$account);
		$this->db->update('user',$data);
	}
	
	function delete_user($account)
	{
		$this->db->delete('user',array('account'=>$account));
	}
	
	function query_user($account)
	{
		$query=$this->db->get_where('user',array('account'=>$account));
		return $query->result_array();
	}
	
	
	function query_all()
	{
		$query=$this->db->get('user');
		return $query->result_array();
	}
	
	function query_user_id($id)
	{
		$query=$this->db->get_where('user',array('ID'=>$id));
		return $query->row_array();
	}
	
	
	
	function query_page($limt,$offest)
	{
		$query =$this->db->get('user',$limt,$offest);
		return $query->result_array();
	}
	
	
	function query_all_number_name()
	{
		$query=$this->db->get('user');
		foreach($query->result() as $row)
		{
			$data['member'][]=$row->Name;
			$data['ID'][]=$row->ID;
		}
		return $data;
	}
	
	
}

?>